<template>
	<view class="page">

		<u-tabs :list="nav" :current="current" @change="change" name="classifyName" bg-color="#F1F1F1"></u-tabs>

		<view class="u-flex u-padding-left-30 u-padding-right-30 u-flex-wrap">
			<view v-for="(item,index) in list" :key="index" class="list" @click="go(item)">
				<view class=" ">
					<u-image :src="item.cover" width="280" height="160" border-radius="10"></u-image>
					<view style="font-weight: bold;margin: 20rpx 0;" class="u-line-1">{{item.goodsName}}</view>
					<view style="font-size: 26rpx;color: #007AFF;font-weight: bold;">{{item.integral}}积分<text
							v-if="Number(item.price)>0"> +{{item.price}}元</text> </view>
				</view>
			</view>
		</view>


		<u-loadmore :status="initial.status" v-if="list.length" />



	</view>


	</view>
</template>

<script>
	import loader from '@/common/loadPage.js';
	export default {
		mixins: [loader],
		data() {

			return {
				tabbar: [],
				nav: [],
				current: 0,
				list: [],
				initial: {
					geturl: "/api/index/integral",
					parm: {
						goods_classify_id: 0
					},
					isPage: true
				},




			}
		},
		async onLoad() {


			await this.goodsClassify()
			this.getGoods()
		},
		methods: {
			go(item) {
				uni.navigateTo({
					url: '../../pages/shop/jifendetail?id=' + item.id
				})
			},
			goodsClassify() {
				return new Promise((resolve, reject) => {
					this.$u.post('/api/index/goodsClassify', {
						type: 2
					}).then(res => {
						res.unshift({
							classifyName: '全部',
							id: 0
						})
						this.nav = res;
						resolve(res)
					}).catch(err => {

					})
				})

			},
			change(index) {
				this.current = index;
				this.initial.parm.goods_classify_id = this.nav[index].id;
				this.getGoods()
			}

		}
	}
</script>


<style>
	.page {
		background: #F1F1F1;
		min-height: 100vh;
	}

	.list {
		background: #fff;
		width: 320rpx;
		margin: 20rpx 12rpx;
		padding: 20rpx;
		border-radius: 10rpx;
	}
</style>
